package com.hospital.controller;

import com.hospital.constant.MessageConstant;
import com.hospital.dto.DoctorPageQueryDTO;
import com.hospital.mapper.DoctorMapper;
import com.hospital.result.PageResult;
import com.hospital.result.Result;
import com.hospital.service.DoctorService;
import com.hospital.vo.DoctorInfoVO;
import com.hospital.vo.DoctorListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/doctor")
@Slf4j
@Api(tags = "1.医生管理")
public class DoctorController {
    @Autowired
    private DoctorService doctorService;

    @GetMapping("/getDoctorList")
    @ApiOperation("获取医生列表")
    public Result<PageResult> getDoctorList(DoctorPageQueryDTO doctorPageQueryDTO) {
        log.info("获取医生列表: {}", doctorPageQueryDTO);
        PageResult page =  doctorService.getDoctorList(doctorPageQueryDTO);
        return Result.success(page, MessageConstant.QUERY_SUCCESS);
    }

    @GetMapping("/getDoctorInfo/")
    @ApiOperation("获取医生信息")
    public Result<DoctorInfoVO> getDoctorInfo(Long doctorId) {
        log.info("获取医生信息: {}", doctorId);
        DoctorInfoVO doctorInfoVO = doctorService.getDoctorInfo(doctorId);
        return Result.success(doctorInfoVO, MessageConstant.QUERY_SUCCESS);
    }
}
